// 封装的是具体的接口请求方法
// 注意：每一个方法负责请求一个url地址
import request from "@/until/request"

// 用户登录
export const loginAPI=({username,password})=>{
    return request({
        url:'/adminapi/user/login',
        method:"POST",
        data:{
            username,
            password
        }
    })
}

// 用户上传头像
export const updateUserAvatarAPI=(avatar,id)=>{
    return request({
        url:'/adminapi/user/updateUserAvatar',
        method:'post',
        data:{
            avatar,
            id
        }
    })
}


// 上传个人信息
export const uploadUserAPI=({username,gender,introduction,avatar,id})=>{
    return request({
        url:'/adminapi/user/uploadUser',
        method:"POST",
        data:{
            username,
            gender,
            introduction,
            avatar,
            id
        }
    })
}

// 添加用户
export const addUserAPI=({username,password,role,introduction,avatar})=>{
    return request({
        url:'/adminapi/user/addUser',
        method:'POST',
        data:{
            username,
            password,
            role,
            introduction,
            avatar
        }
    })
}

//获取所有用户信息
export const allUserAPI=()=>{
    return request({
        url:"/adminapi/user/allUser",
        method:'GET'
    })
}

// 删除用户
export const deleteUserAPI=(id)=>{
    return request({
        url:"/adminapi/user/deleteUser",
        method:'delete',
        data:{
            id
        }
    })
}

// 修改用户信息
export const editUserAPI=({username,password,role,introduction,avatar,id})=>{
    return request({
        url:'/adminapi/user/editUser',
        method:'put',
        data:{
            username,
            password,
            role,
            introduction,
            avatar,
            id
        }
    })
}


// 添加新闻信息
export const addNewAPI=({title,content,category,cover})=>{
    return request({
        url:'/adminapi/new/addNew',
        method:'POST',
        data:{
            title,
            content,
            category,
            cover
        }
    })
}

// 获取新闻信息
export const getNewAPI=()=>{
    return request({
        url:'/adminapi/new/getNew',
        method:'get'
    })
}

// 是否发布
export const changeNewSwitchAPI=({id,isPublish})=>{
    return request({
        url:'/adminapi/new/changNewSwtich',
        method:'PUT',
        data:{
            id,
            isPublish
        }
    })
}

// 删除新闻
export const deleteNewAPI=(id)=>{
    return request({
        url:'/adminapi/new/deleteNew',
        method:'delete',
        data:{
            id
        }
    })
}

// 获取当前新闻信息
export const getNewCurrentAPI=(id)=>{
    return request({
        url:'/adminapi/new/getNewCurrent',
        method:'get',
        params:{
            id
        }
    })
}

// 编辑新闻信息
export const editNewAPI=({title,content,category,cover,id})=>{
    return request({
        url:'/adminapi/new/editNew',
        method:'POST',
        data:{
            title,
            content,
            category,
            cover,
            id
        }
    })
}

// 新增产品详细
export const addProductAPI=({title,author,introduction,detail,cover})=>{
    return request({
        url:"/adminapi/product/addProduct",
        method:'POST',
        data:{
            title,
            author,
            introduction,
            detail,
            cover
        }
    })
}

// 更新产品
export const editProductAPI=({title,author,introduction,detail,cover,id})=>{
    return request({
        url:"/adminapi/product/editProduct",
        method:'POST',
        data:{
            title,
            author,
            introduction,
            detail,
            cover,
            id
        }
    })
}

// 获取产品信息
export const getProductAPI=()=>{
    return request({
        url:'/adminapi/product/getProduct',
        method:'get'
    })
}

// 删除产品信息
export const deleteProductAPI=(id)=>{
    return request({
        url:"/adminapi/product/deleteProduct",
        method:'delete',
        params:{
            id
        }
    })
}

// 编辑当前的产品信息
export const getCurrentProductAPI=(id)=>{
    return request({
        url:"/adminapi/product/getCurrentProduct",
        method:'get',
        params:{
            id
        }
    })
}

// 添加企业信息
export const addCompnayAPI=({...company})=>{
    return request({
        url:'/adminapi/company/addCompany',
        method:"POST",
        data:{
            ...company
        }
    })
}

// 获取企业信息
export const allCompanyAPI=()=>{
    return request({
        url:'/adminapi/company/allCompany',
        method:"GET"
    })
}

// 更新企业
export const updateCompanyAPI=({...company})=>{
    return request({
        url:"/adminapi/company/updateCompany",
        method:'POST',
        data:{
            ...company
        }
    })
}

// 添加轮播
export const addCarouselAPI=({...carousel})=>{
    return request({
        url:'/adminapi/carousel/addCarousel',
        method:"POST",
        data:{
            ...carousel
        }
    })
}

// 获取所有轮播图
export const allCarouselAPI=()=>{
    return request({
        url:'/adminapi/carousel/allCarousel',
        method:"GET"
    })
}


// 编辑轮播
export const editCarouselAPI=({...carousel})=>{
    return request({
        url:'/adminapi/carousel/editCarousel',
        method:"POST",
        data:{
            ...carousel
        }
    })
}


// 删除轮播图
export const deleteCarouselAPI=(id)=>{
    return request({
        url:"/adminapi/carousel/deleteCarousel",
        method:'delete',
        params:{
            id
        }
    })
}

// 添加合作企业
export const addCooperationAPI=({...cooperation})=>{
    return request({
        url:'/adminapi/cooperation/addCooperation',
        method:"POST",
        data:{
            ...cooperation
        }
    })
}

// 获取合作企业信息
export const allCooperationAPI=() => {
    return request({
        url:"adminapi/cooperation/allCooperation",
        method:"get"
    })
}

// 编辑企业合作信息
export const editCooperationAPI=(({...cooperation}) => {
    console.log("object",cooperation);
    return request({
        url:"adminapi/cooperation/editCooperation",
        method:"POST",
        data:{
            ...cooperation
        }
    })
})

// 删除企业合作信息
export const deleteCooperationAPI=((cooperationId) => {
    return request({
        url:"adminapi/cooperation/deleteCooperation",
        method:"delete",
        params:{
            cooperationId
        }
    })
})


// 获取留言反馈信息
export const allFeedbackAPI=() => {
    return request({
        url:"adminapi/feedback/allFeedback",
        method:"get"
    })
}

// 删除留言反馈信息
export const deleteFeedbackAPI=((id) => {
    return request({
        url:"adminapi/feedback/deleteFeedback",
        method:"delete",
        params:{
            id
        }
    })
})


// 编辑留言反馈，已回复
export const handleEditReplyAPI=((id) => {
    return request({
        url:"adminapi/feedback/editFeedbackReply",
        method:"POST",
        data:{
            id
        }
    })
})

